<script language="javascript">
function initPage(){
    var pageForm = document.getElementById("###searchForm###");
    var contentDiv = document.getElementById("###content###");
    var funName = "###fun###";
    var fun = null;
    if(!pageForm){
       alert("###searchForm###" + "表单不存在");
       return false;
    }
    if(!contentDiv){
       alert("###content###" + "刷新DIV不存在");
       return false;
    }
    if(funName!= ""){
        var fun = eval(funName);
        if(!fun){
            alert("###fun###" + "方法不存在");
        }
    }
    return {pageForm:pageForm,contentDiv:contentDiv,fun:fun};
}
function goPage(page){
    var initParam = initPage();
    var pageForm = initParam.pageForm;
    if(!isNumber(page) || page == 0 || page > parseInt("###maxRows###")){
       alert("###ERROR_PAGE_NUMBER###")
       return false;
    }
    //pageForm.reset();
    pageForm.page.value = page;
    pageAjaxSubmit(initParam);
}
function pageAjaxSubmit(initParam){
    var pageForm = initParam.pageForm;
    var rowsPerPage = initParam.pageForm.rowsPerPage.value;
    var page = pageForm.page.value;
    var url = pageForm.action.toString();
    var type =  pageForm.method.toString();
    var fun = initParam.fun;
    var data = '&page=' + page + '&rowsPerPage=' + rowsPerPage;
    var contentDiv = initParam.contentDiv;
    if(fun){
        var funParam = fun();
        if(!funParam.returnValue){
            return;
        }
        if(funParam.param){
          data += "&" + funParam.param;
        }
    }
    if( !type || type == "" ){
    	type = "POST";
    }
    $.ajax({
        url: url,
        type: type,
        dataType: 'html',
        data:data,
        timeout: 1000,
        cache: false,
        async: false,
        error: function() {

        },
        success: function(html) {
            contentDiv.innerHTML = html;
        }
    });
}

function setRowsPerPage(rows){
    var initParam = init();
		var f = initParam.pageForm;
 		f.reset();
    f.rowsPerPage.value=rows;
    pageAjaxSubmit(initParam);
}

function isNumber(str){
    var number_chars = "1234567890";
    var i;
    for (i=0;i<str.length;i++) {
        if (number_chars.indexOf(str.charAt(i))==-1)
            return false;
    }
    return true;
}
</script>